home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / lib / mntlib44.zoo / mntlib / flock.c < prev    next >
C/C++ Source or Header  |  1994-03-01  |  454b  |  28 lines

  1. /*
  2.  * lockf(3) and flock(2) emulation for MiNT by Dave Gymer
  3.  * Placed in the public domain; do with me as you will!
  4.  */
  5.  
  6. #include <errno.h>
  7. #include <fcntl.h>
  8. #include <unistd.h>
  9. #include <file.h>
  10. #include "lib.h"
  11.  
  12. int
  13. flock(fd, op)
  14.     int fd, op;
  15. {
  16.     int cmd;
  17.  
  18.     if (op & (LOCK_SH | LOCK_EX))
  19.         cmd = (op & LOCK_NB) ? F_TLOCK : F_LOCK;
  20.     else if (op & LOCK_UN)
  21.         cmd = F_ULOCK;
  22.     else {
  23.         errno = -EINVAL;
  24.         return -1;
  25.     }
  26.     return _do_lock(fd, cmd, 0L, 0);
  27. }
  28.